﻿using UnityEngine;
using System.Collections;
using UnityEditor;
using XLua;

[Hotfix]
public class HotfixByFile : MonoBehaviour
{
    public LuaEnv luaEnv;

    // Use this for initialization
    void Start()
    {
        luaEnv = new LuaEnv();
        //在lua中打补丁替换掉此方法
        luaEnv.DoString(" require 'hot_something' ");
    }

    void OnGUI()
    {
        if (GUILayout.Button("Do Logic"))
        {
            DoSomething();
        }
    }

    void Update()
    {
        if (luaEnv != null) luaEnv.Tick();
    }


    void OnDestory()
    {
        if (luaEnv != null) luaEnv.Dispose();
    }

    void DoSomething()
    {
        Debug.Log("logic  by csharp");
    }
}
